#include "pch.h"
#include "PreconditionVisitor.h"
#include <osg/Geode>
#include <osg/Geometry>

void PreconditionVisitor::apply(osg::Geometry &geometry)
{
	osg::ref_ptr<osg::StateSet> set1 = geometry.getStateSet();
	if (set1.valid())
	{
		//osg::StateAttribute * abute = 

		for (int i = 0; i < 8; ++i)
		{
			osg::StateAttribute* attrItem1 = set1->getTextureAttribute(i, osg::StateAttribute::TEXTURE);
			if (NULL != attrItem1)
			{
				switch (i)
				{
				case 2:
				{
					osg::ref_ptr<osg::Uniform> uniformUserReflectTextureUsed = new osg::Uniform("ReflectTextureUsed", true);
					uniformUserReflectTextureUsed->setType(osg::Uniform::Type::BOOL);
					set1->addUniform(uniformUserReflectTextureUsed);

					osg::ref_ptr<osg::Uniform> uniformUserReflectTexture = new osg::Uniform("ReflectTexture", 2);
					set1->addUniform(uniformUserReflectTexture);
					break;
				}
				}
			}
		}
	}
}